.token-field {
	@extend %form-field;

	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 0;
	background-color: $white;
	border: 1px solid lighten( $gray, 20% );
	color: $gray-dark;
	cursor: text;
	transition: all .15s ease-in-out;

	&:hover {
		border-color: lighten( $gray, 10% );
	}

	&.is-disabled {
		background: $gray-light;
		border-color: lighten( $gray, 30% );
	}

	&.is-active {
		border-color: $blue-wordpress;
		box-shadow: 0 0 0 2px $blue-light;
	}
}

.token-field__input-container {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	padding: 5px 14px 5px 0;
}

// Token input
input[type="text"].token-field__input {
	display: inline-block;
	width: auto;
	max-width: 100%;
	margin: 2px 0 2px 8px;
	padding: 0 0 0 6px;
	line-height: 24px;
	background: inherit;
	border: 0;
	outline: none;
	font-family: inherit;
	font-size: 14px;
	color: $gray-dark;

	&:focus {
		box-shadow: none;
	}
}

// Tokens
.token-field__token {
	font-size: 14px;
	display: flex;
	margin: 2px 0 2px 8px;
	color: $white;
	overflow: hidden;

	&.is-success {
		.token-field__token-text,
		.token-field__remove-token {
			background: $alert-green;
		}
	}

	&.is-error {
		.token-field__token-text,
		.token-field__remove-token {
			background: $alert-red;
		}
	}

	&.is-validating {
		.token-field__token-text,
		.token-field__remove-token {
			background: $gray;
		}
	}

	&.is-borderless {
		position: relative;
		padding: 0 16px 0 0;

		.token-field__token-text {
			background: transparent;
			color: $blue-wordpress;
		}

		.token-field__remove-token {
			background: transparent;
			color: $gray;
			position: absolute;
			top: 1px;
			right: 0;
		}

		&.is-success {
			.token-field__token-text {
				color: $alert-green;
			}
		}

		&.is-error {
			.token-field__token-text {
				color: $alert-red;
				border-radius: 4px 0 0 4px;
				padding: 0 4px 0 6px;
			}
		}

		&.is-validating {
			.token-field__token-text {
				color: $gray-dark;
			}
		}
	}

	&.is-disabled {
		.token-field__remove-token {
			cursor: default;
		}
	}
}

.token-field__token-text,
.token-field__remove-token {
	display: inline-block;
	line-height: 24px;
	background: darken( $gray, 20% );
	transition: all .2s cubic-bezier( .4, 1, .4, 1 );
}

.token-field__token-text {
	border-radius: 4px 0 0 4px;
	padding: 0 4px 0 6px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.token-field__remove-token {
	cursor: pointer;
	border-radius: 0 4px 4px 0;
	padding: 0 6px;
	font-size: 10px;
	color: lighten( $gray, 20% );

	&:hover {
		color: white;
		background: darken( $gray, 10% );
	}
}

// Suggestion list
.token-field__suggestions-list {
	background: $white;
	max-height: 0;
	overflow-y: scroll;
	transition: all .15s ease-in-out;
	list-style: none;
	margin: 0;

	&.is-expanded {
		background: $white;
		border-top: 1px solid lighten( $gray, 20% );
		max-height: 9em;
		padding-top: 3px;
	}
}

.token-field__suggestion {
	color: $gray;
	display: block;
	font-size: 13px;
	padding: 4px 8px;
	cursor: pointer;

	&.is-selected {
		background: $blue-medium;
		color: $white;
	}
}

.token-field__suggestion-match {
	color: $gray-dark;
}
